package com.fyzk.betzhushu.nxk3;

import java.math.BigInteger;
import java.util.List;

import com.fyzk.activity.lottery.shuzicai.BallInfo;
import com.fyzk.betzhushu.ZhuShuBase;

public class Nxk3SanBuTong extends ZhuShuBase{

	private int num = 3;
	@Override
	public long betZhuShu(List<List<BallInfo>> balls) {
		int count = 0;
		int count_sanLianHao = 0;
		List<BallInfo> infos = balls.get(5);
		for (int i = 0; i < infos.size(); i++) {
			if (i != infos.size() - 1 && infos.get(i).isSelected()) {
				count++;	
			}
		}
		
		if (infos.get(infos.size() - 1).isSelected()) {
			count_sanLianHao = 1;
		}
		return getZhuShu_common(count) + count_sanLianHao;
	}
	
	/**
	 * 计算注数(任选n)
	 */
	private long getZhuShu_common(int hong){
		if (hong < num) {
			return 0;
		}else{
			BigInteger big = c_x_y(hong).divide(c_x_y(num)).divide(c_x_y(hong - num));
			return  big.longValue();
		}
	}
	
	private BigInteger c_x_y(int n){
		BigInteger big = new BigInteger(""+n);
		
		return (n == 0) ? new BigInteger("1") : big.multiply(c_x_y(n - 1)) ;
	}

}
